#include <allegro.h>
#include <stdio.h>
#include "fight.h"


int main() 
{

	char chemin_background[]="../images/background.bmp";

	BITMAP *Buffer;
	BITMAP *Background=NULL;
	BITMAP *Image;
	
	int compteur;
	MB mini;
	richard r;

	/* General initialization function */
	allegro_init();
	if (install_keyboard() == -1) {
		allegro_message("Error! %s", allegro_error);
		return (-1);
	}
	set_color_depth(16);
	if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 600, 800, 0, 0) != 0) {
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); /* here’s the command for text mode */
		allegro_message("Unable to initialize video mode!\n%s\n", allegro_error);
		return 1;
	}
 

Buffer = create_bitmap(SCREEN_W, SCREEN_H);


load_MB(&mini);
load_R(&r);

Background=load_background_bmp(chemin_background);

Image = load_bitmap("../images/r0.bmp", NULL); 

	compteur = 0;
	init_MB(&mini);
	init_R(&r,Image->h,Image->w);

	while (!key[KEY_ESC]) {

			//vider le buffer
		clear_bitmap(Buffer);


//drawing background
draw_background(Background,Buffer);

//drawing MB & Richard
draw_sprite(Buffer, mini.img_face, mini.x, mini.y);
draw_MB(mini,Buffer,compteur);
draw_R(r,Buffer,compteur);


//if( mini.is_alive==1)
//{
// Mvt MB
move_MB_right(&mini,Background);
move_MB_left(&mini,Background);
// Mvt Richard
mouvement_richard(&r,Background,Buffer);
/*
// Collision
mini.coll=Collision(r,mini);

//Fight
fight(&mini,&r);
main_fight(&r, &mini);

}
*/

//blit Buffer to screen
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);

		if (compteur == 10000)
		{
			compteur = 0;
		}
	}

destroy_MB(&mini);
destroy_R(&r);
destroy_background(Background);
destroy_bitmap(Buffer);

	return 0;
}
END_OF_MAIN();



